#include<iostream>
using namespace std;
struct TreeNode {
    int val;
    struct TreeNode *left;
    struct TreeNode *right;
 };

int maxdepth(struct TreeNode *root,int height,int mm)
{
    if(root==NULL)
    {
        return height--;
    };
    height++;
    mm=max(mm,height);
    mm=max(maxdepth(root->right, height,mm),mm);
    mm=max(mm,maxdepth(root->left, height,mm));
    return mm;
}

int maxDepth(struct TreeNode* root){
    return maxdepth(root,0,0);
}